/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SMeterInputConverter.java
 * Created：		2016年8月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.notice.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.common.AAttachment2Converter;
import com.thor.palmmall.rest.common.OperateInfoConverter;
import com.thor.palmmall.rest.notice.ANotice;
import com.thor.palmmall.spi.notice.SNotice;

/**
 * @author wolv
 *
 */
public class ANoticeConverter implements Converter<SNotice, ANotice> {

	public static ANoticeConverter getInstance() {
		if (instance == null)
			instance = new ANoticeConverter();
		return instance;
	}

	private static ANoticeConverter instance;

	private ANoticeConverter() {
	}

	@Override
	public ANotice convert(SNotice source) {
		if (source == null)
			return null;

		ANotice target = new ANotice();
		target.setAttachments(ConverterUtil.convert(source.getAttachments(), AAttachment2Converter.getInstance()));
		target.setContent(source.getContent());
		target.setRemark(source.getRemark());
		target.setTitle(source.getTitle());
		target.setUuid(source.getUuid());
		target.setValidBeginDate(source.getValidBeginDate());
		target.setValidEndDate(source.getValidEndDate());
		target.setPublisher(OperateInfoConverter.getInstance().convert(source.getCreateInfo()));
		target.setAbortMsg(source.getAbortMsg());

		return target;
	}

}
